package com.hwd.srb.core.enmu;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @author 黄伟东/Victor
 * @date 2022/3/25 11:27
 * @Description 资金用途枚举
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum MoneyUseEnum {

    TRAVEL(1, "旅游"),
    BUY_HOUSE(2, "买房"),
    DECORATION(3, "装修"),
    MEDICINE(4, "医疗"),
    FACIAL(5, "美容"),
    OTHER(6, "其他"),
    ;

    @EnumValue
    private Integer value;

    @JsonValue
    private String moneyUse;

    @Override
    public String toString() {
        return this.moneyUse;
    }

    public static String getMoneyUseByValue(int value) {
        return Arrays.stream(MoneyUseEnum.values())
                .filter(i -> i.getValue() == value)
                .map(MoneyUseEnum::getMoneyUse)
                .findFirst()
                .orElse("");
    }
}
